<?php
/**
 * Skeleton Template for Joomla Components
 * Copyright (C) 2009 Think Network GmbH, Munich - All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * -----------------------------------------------------------------------------
 * $Id: skeleton.php 1344 2009-06-18 11:50:09Z akede $
 * @package skeleton
 * @subpackage skeleton
 *
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.controller');

/**
 * Skelleton Controller, best practise for a full implementation of the MCV in a module
 * 
 * @version 0.5
 */
class ModSkeletonController extends JController {
	
	/**
	 * @var string
	 */
	private $layout='default';
	/**
	 * @var string
	 */
	private $parameter1=null;

	/**
	 * Constructor for the controller retrieving the primary required parameters
	 * 
	 * @param $params	array of module parameters
	 * @return ModSkeletonController instance
	 */
	function __construct($params) {
		parent::__construct($params);
		parent::addModelPath(MODCHART_PATH.DS.'models');

		// get the layout of the module based on the module/menu configuration
		$layout = $params->get('layout', 'default');
		$this->layout = JFilterInput::clean($layout, 'word');
		
		// get parameters from the request
		$this->parameter1	= $params->get( 'parameter1', null );
	}
	
	/**
	 * Renders the content of the module based on the controller requirements
	 * @return string content of the module
	 */
	public function render() {
		$path = JModuleHelper::getLayoutPath('mod_skeleton', $this->layout);
		$content = '';
		if (file_exists($path)) {
			ob_start();
			require($path);
			$content = ob_get_contents();
			ob_end_clean();
		}
		return $content;
	}
}